import request from "./Request.js";
// 获取音乐 url
const getSongUrl = async (id) => {
    let result = await request.get(`/song/url?id=${id}`);
    if (result.code === 200) {
        return result.data;
    }
    return null;
}
// 刷新登录状态
const refreshLogin = async () => {
    let result = await request(`/login/refresh`);
    console.log(result)
}
// 获取歌单详情
const getSongSheetDetail = async (id) => {
    let result = await request(`/playlist/detail?id=${id}`)
    if (result.code === 200) {
     return result.playlist;
    }
}
// 获取歌单所有歌曲     limit : 限制获取歌曲的数量，默认值为当前歌单的歌曲数量
const getSongSheetSongList = async (id) => {
    let result = await request(`/playlist/track/all?id=${id}`)
    if (result.code === 200) {
        return result.songs
    }
}
// 获取热门歌手  默认limit50条，偏移offset 0
const getHotSinger = async (limit = 50) => {
    let result = await request(`/top/artists?limit=${limit}`);
    if (result.code === 200) {
        return result.artists;
    }
}
// 获取获得歌手部分信息和热门歌曲  id = 歌手id
const getSingerInfo = async (id) => {
    let result = await request(`/artists?id=${id}`);
    console.log(result)

    if (result.code === 200) {
        return result;
    }
}
// 获取歌手详情
const getDetailSinger = async (id) => {
    let result = await request.post(`/artist/detail?id=${id}`);
    if (result.code === 200) {
        return result;
    }
}
// 歌手热门 50 首歌曲
const getSingerHotSongs = async (id) => {
    let result = await request(`/artist/top/song?id=${id}`)
    if (result.code === 200) {
        console.log(result);
    }
}
// 获取歌手分类列表
const getSingerCategoryList = async ({limit = 30, offset = 0, area = -1, type = -1}) => {
    ///artist/list?type=1&area=96&initial=b
    let result = await request(`/artist/list?limit=${limit}&offset=${offset}&area=${area}&type=${type}`);
    if (result.code === 200) {
        return result;
    }
};
// 获取用户详情
const getUserDetail = async () => {
    //32953014  8023474819
    let result = await request(`/user/detail?uid=8367423645`);
    console.log("用户详情" + result);
};
// 获取歌曲详情 ids
const getSongDetail = async (id) => {
    let result = await request.get(`/song/detail?ids=${id}`);
    if (result.code === 200) {
        console.log(result)
    }
};
const api = {
    getSongUrl,
    refreshLogin,
    getSongSheetDetail,
    getSongSheetSongList,
    getHotSinger,
    getSingerInfo,
    getSingerHotSongs,
    getSingerCategoryList,
    getDetailSinger,
    getUserDetail,
    getSongDetail
}
export default api;





// // 获取推荐歌单 默认30条 limit
// const getRecommendedSongSheet = async () => {
//     let result = await request.get("/personalized?limit=5");
//     if (result.code === 200) {
//     }
// };